﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace _3.AnyWordWithSubstring
{
    class Program
    {
        static void Main(string[] args)
        {
            string input;
            string substring = "est";

            input = "Testing, is pest and festorant und est est.";
            PrintAllWordsThatContain(input, substring);
        }

        private static void PrintAllWordsThatContain(string input, string substring)
        {
            string pattern = String.Format(@"\b\w*{0}\w*\b", substring); 

            Regex regex = new Regex(pattern);
            var matches = regex.Matches(input);

            foreach (var m in matches)
            {
                Console.WriteLine(m);
            }
        }
    }
}
